package com.gopay.common.exception;

import org.apache.commons.lang.StringUtils;

/**
 * 交易异常
 * 
 * @TransGopayException.java
 * @author yaobo
 * @2012-12-19 上午11:21:52 www.gopay.com.cn Inc.All rights reserved.
 */
public class TransException extends GopayException {

    /**
     * 
     */
    private static final long serialVersionUID = -7110011852507526263L;

    /**
     * 内部订单号
     */
    private String gopayOrderId;

    /**
     * 商户代码
     */
    private String merOrderNum;

    /**
     * 商户订单号
     */
    private String merchantId;

    public TransException() {
        super();
    }

    public TransException(String gopayOrderId, String errCode) {
        super();
        this.gopayOrderId = gopayOrderId;
        this.errCode = errCode;
    }

    public TransException(String merOrderNum, String merchantId, String errCode) {
        super();
        this.merOrderNum = merOrderNum;
        this.merchantId = merchantId;
        this.errCode = errCode;
    }

    /**
     * 打印错误信息
     */
    @Override
    public String printErrMsg() {
        StringBuffer msg = new StringBuffer("");

        if (StringUtils.isNotBlank(errCode)) {
            msg.append("Exception errCode is [").append(this.errCode).append("];\n");
        }

        if (StringUtils.isNotBlank(gopayOrderId)) {
            msg.append("Exception orderId is [").append(this.gopayOrderId).append("];\n");
        }

        if (StringUtils.isNotBlank(merOrderNum)) {
            msg.append("Exception merOrderNum is [").append(this.merOrderNum).append("];\n");
        }

        if (StringUtils.isNotBlank(merchantId)) {
            msg.append("Exception merchantId is [").append(this.merchantId).append("];\n");
        }

        return msg.toString();
    }

    public String getGopayOrderId() {
        return gopayOrderId;
    }

    public String getMerOrderNum() {
        return merOrderNum;
    }

    public String getMerchantId() {
        return merchantId;
    }

}
